<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui">


    <ui:define name="content">



        <h:form  >
            <p:growl />
            <p:focus id="selectFocus" context="gpSelect" />
            <p:focus id="detailFocus" context="gpDetail" />



            <p:panel  >

                <f:facet name="header" >
                    <h:outputLabel value="Manage Pharmaceutical Item Types" ></h:outputLabel>
                    <p:commandButton value="Back" ajax="false" action="/pharmacy/pharmacy_admin" icon="ui-icon-circle-triangle-w" style="float: right;" ></p:commandButton>
                </f:facet>

                <h:panelGrid id ="gpVeda" columns="2" styleClass="alignTop">

                    <h:panelGrid id="gpSelect" columns="1"  >
                        <p:panel >
                            <h:panelGrid id="gpSelectText" >
                                <h:selectOneListbox  id="lstSelect"   size="10" value="#{pharmaceuticalItemTypeController.current}" style="min-width: 223px">
                                    <f:selectItems  value="#{pharmaceuticalItemTypeController.items}" var="myItem" itemValue="#{myItem}" itemLabel="#{myItem.name}" ></f:selectItems>
                                    <f:ajax render="gpDetail" execute="lstSelect" >
                                    </f:ajax>
                                </h:selectOneListbox>
                            </h:panelGrid>
                            <h:panelGrid id="gpSelectButtons" columns="3"  >
                                <h:commandButton id="btnAdd" value="Add" action="#{pharmaceuticalItemTypeController.prepareAdd()}" styleClass="buttons" >
                                    <f:ajax render="btnAdd  btnDelete btnSave   lstSelect gpDetail detailFocus" execute="" >
                                    </f:ajax>
                                </h:commandButton>

                                <h:commandButton id="btnDelete" onclick="if (!confirm('Are you sure you want to delete this record?'))
                                                return false;" action="#{pharmaceuticalItemTypeController.delete()}"  value="Delete"  >
                                </h:commandButton>
                            </h:panelGrid>
                        </p:panel>
                    </h:panelGrid  >

                    <p:panel>
                        <h:panelGrid id="gpDetail" columns="1">
                            <h:panelGrid id="gpDetailText" columns="2">
                                <h:outputText id="lblName" value="Name" ></h:outputText>
                                <h:inputText autocomplete="off" id="txtName" value="#{pharmaceuticalItemTypeController.current.name}"  ></h:inputText>                                    

                                <h:outputText  value="Sale Margin" ></h:outputText>
                                <h:inputText autocomplete="off" value="#{pharmaceuticalItemTypeController.current.saleMargin}"  ></h:inputText>
                                <h:outputText  value="Whole Sale Margin" ></h:outputText>
                                <h:inputText autocomplete="off"  value="#{pharmaceuticalItemTypeController.current.wholeSaleMargin}"  ></h:inputText>
                            </h:panelGrid>
                            <h:panelGrid id="gpDetailButtons" columns="2">
                                <h:commandButton id="btnSave" value="Save" action="#{pharmaceuticalItemTypeController.saveSelected()}" styleClass="buttons">
                                    <f:ajax render="btnAdd  btnDelete btnSave   lstSelect gpDetail selectFocus"  execute="gpDetail" >
                                    </f:ajax>
                                </h:commandButton>
                                <p:defaultCommand target="btnSave"/>

                            </h:panelGrid>
                        </h:panelGrid>
                    </p:panel>
                </h:panelGrid>
            </p:panel>
        </h:form>



    </ui:define>

</ui:composition>
